function Level_Info(inst)
	if inst.components.musha_skills then
		inst.components.musha_skills:Level_Info(inst)
	end

	if inst.components.musha_leader then
		local x, y, z = inst.Transform:GetWorldPosition()
		local ents = TheSim:FindEntities(x, y, z, 25, {"yamche"})
		for k, v in pairs(ents) do
			if inst.components.leader:IsFollower(v) and v.components.follower.leader then
				v.yamche_info()
			end
		end
	end
end

function SpecialAttackSwitch(inst)
	inst.components.musha_skills:SpecialAttackSwitch(inst)
end

function ElectricShield(inst)
	inst.components.musha_skills:ElectricShield(inst)
end
function Sing(inst)
	inst.components.musha_skills:Sing(inst)
end
function Sniff(inst)
	inst.components.musha_skills:Sniff(inst)
end
function Sleep_Switch(inst)
	inst.components.musha_skills:Sleep_Switch(inst)
end
function ShadowHide(inst)
	inst.components.musha_skills:ShadowHide(inst)
end

function Order_Musha_Beefalo(inst)
	inst.components.musha_leader:Order_Musha_Beefalo(inst)
end

function Order_Musha_Yamche_1(inst) --follow
	inst.components.musha_leader:Order_Musha_Yamche_1(inst)
end

function Order_Musha_Yamche_2(inst) --action
	inst.components.musha_leader:Order_Musha_Yamche_2(inst)
end

function Order_Musha_MoonTree(inst)
	inst.components.musha_leader:Order_Musha_MoonTree(inst)
end

function Skill_UI(inst, data)
	local TheWorld = GLOBAL.TheWorld
	--local ThePlayer = GLOBAL.ThePlayer
	if TheNet:GetIsClient() or (inst and inst.HUD) then
		if inst.HUD.controls.musha_skill_menu.shown then
			inst.HUD.controls.musha_skill_menu:OnSave()
		else
			data =
				data or
				{
					found_treasure_count = TheWorld.Musha_Watcher.found_treasure_count,
					all_treasure_count = TheWorld.Musha_Watcher.all_treasure_count
				}
			inst.HUD.controls.musha_skill_menu:ReFlash(inst, data)
			inst.HUD.controls.musha_skill_menu:Show()
		end
	else
		inst.player_classified:PushEvent(
			"musha_skillmenuswitch",
			string.format("%d %d", TheWorld.Musha_Watcher.found_treasure_count, TheWorld.Musha_Watcher.all_treasure_count)
		)
	end
end

function Upload_SkillData(inst, name, data)
	inst.replica.musha_skills:SetData(name, data)
end

AddModRPCHandler("musha", "Level_Info", Level_Info)
AddModRPCHandler("musha", "Skill_UI", Skill_UI)
AddModRPCHandler("musha", "SpecialAttackSwitch", SpecialAttackSwitch)
AddModRPCHandler("musha", "ElectricShield", ElectricShield)
AddModRPCHandler("musha", "Sing", Sing)
AddModRPCHandler("musha", "Sniff", Sniff)
AddModRPCHandler("musha", "Sleep_Switch", Sleep_Switch)
AddModRPCHandler("musha", "ShadowHide", ShadowHide)
AddModRPCHandler("musha", "Order_Musha_Beefalo", Order_Musha_Beefalo)
AddModRPCHandler("musha", "Order_Musha_Yamche_1", Order_Musha_Yamche_1)
AddModRPCHandler("musha", "Order_Musha_Yamche_2", Order_Musha_Yamche_2)
AddModRPCHandler("musha", "Order_Musha_MoonTree", Order_Musha_MoonTree)
AddModRPCHandler("musha", "Upload_SkillData", Upload_SkillData)
